from visual import *
from Blokus import *
from PieceTest import *


def draw_piece(piece,n):
    color_index = [color.red,color.blue,color.green,color.yellow]
    for (x,y) in piece.geometry:
        box (pos = (-100 + x+n,y,0),size = (2,2,1), color = color_index[piece.color])



selected = display(title = 'Selected piece', x = 0, y = 10**6, width = 200,
                       height = 200, center = (0,0,0), background = (1,1,1),
                       userzoom = False)
board = display(width = 1000, height = 1000, center = (0, 0, 0),
                       userzoom = False, background = (0, 0, 1))
hand = display(x = 100, y = 10**6, width = 1000, height = 200,
                       background = (0,1,1), userzoom = False)

board.visible = True
selected.visible = True
hand.visible = True


p = Piece(3,2)
draw_piece(p, 10)

while True:
    if hand.mouse.getclick():
        obj = hand.mouse.pick #each piece needs to be printed as a single object
        selected.select()
        draw_piece(obj,0)
